#include <lib.h>
#include <unistd.h>

PUBLIC int seminit(int sem, int value)
{
    message m;
    m.m1_i1 = sem;
    m.m1_i2 = value;

    return(_syscall(PM_PROC_NR, SEMINIT, &m));
}

PUBLIC int semfree(int sem)
{
    message m;
    m.m1_i1 = sem;
    
    return(_syscall(PM_PROC_NR, SEMFREE, &m));
}

PUBLIC int semdown(int sem)
{
    message m;
    m.m1_i1 = sem;

    return(_syscall(PM_PROC_NR, SEMDOWN, &m));
}

PUBLIC int semup(int sem)
{
    message m;
    m.m1_i1 = sem;

    return(_syscall(PM_PROC_NR, SEMUP, &m));
}

PUBLIC int semvalue(int sem)
{
    message m;
    m.m1_i1 = sem;

    _syscall(PM_PROC_NR, SEMVALUE, &m);

	int semvalue = m.m2_i1;
	printf("Semvalue: %d\n", semvalue);

	return 0;
}
